import { createApp } from 'vue'
import './style.scss'
import App from './App.vue'
import ElementPlus from 'element-plus'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import 'element-plus/dist/index.css'
import 'animate.css'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import permission from './directives/permission'
import router from './router'
import { stopHeartbeat } from './utils/heartbeat'
import '@wangeditor/editor/dist/css/style.css'

const app = createApp(App)
app.use(router)
app.use(ElementPlus, {
    locale: zhCn,
  })
  for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
  }

  app.directive('permission', permission)
  // 创建pinia实例
  const pinia = createPinia()
  // 持久化插件
  pinia.use(piniaPluginPersistedstate)
  app.use(pinia)



  // 处理浏览器关闭/刷新
window.addEventListener('beforeunload', () => {
  stopHeartbeat()
})

app.mount('#app')
